package com.mianyang.zhangsan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mianyang.zhangsan.model.entity.SecAccount;
import com.mianyang.zhangsan.model.entity.SecDept;
import com.mianyang.zhangsan.mapper.SecDeptMapper;
import com.mianyang.zhangsan.service.ISecAccountService;
import com.mianyang.zhangsan.service.ISecDeptService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jiangjr
 * @since 2022-10-23
 */
@Service
public class SecDeptServiceImpl extends ServiceImpl<SecDeptMapper, SecDept> implements ISecDeptService {
    @Autowired
    private ISecAccountService accountService;

    @Override
    public SecDept selectDept(@NonNull Long userId) {
        SecAccount account = accountService.selectSelfAccount(userId);
        if (account != null) {
            return baseMapper.selectById(account.getDeptId());
        }
        return null;
    }
}
